<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:insert="~{include :: header('课程列表')}" />
    <th:block th:insert="~{include :: bootstrap-table-css}" />
</head>
<body class="hold-transition">

<div class="container-fluid mb-2">
    <div class="toolbar" id="toolbar" role="group">
        <form id="formId" class="form-inline">
            <input type="text" class="form-control mr-1" name="courseName" placeholder="课程名称">
            <select class="form-control mr-1" name="subjectId">
                <option value="0">专业</option>
                <option th:each="subject : ${subjectList}" th:value="${subject.subjectId}" th:text="${subject.subjectName}">室内设计</option>
            </select>
            <button type="button" class="btn btn-primary mr-1" onclick="$.table.search()">
                <i class="fa fa-search"></i>
                搜索
            </button>
            <button type="button" class="btn btn-default" onclick="$.form.reset()">
                <i class="fa fa-refresh"></i>
                重置
            </button>
        </form>
    </div>
    <table id="bootstrap-table" class="table-striped"></table>
    <div class="col-sm-offset-2 col-sm-10" style="margin-top: 20px;margin-bottom: 30px">
        <button type="button" class="btn btn-primary" onclick="courseChoice()"><i class="fa fa-check"></i>保 存</button>&nbsp;
        <button type="button" class="btn btn-danger" onclick="closeIndesx()"><i class="fa fa-reply-all"></i>关 闭 </button>
    </div>
</div>
<th:block th:insert="~{include :: footer}" />
<th:block th:insert="~{include :: bootstrap-table-js}" />
<script th:inline="javascript">
    var prefix = "/type";
    $(function() {
        var options = {
            url: "/member/course/select.json",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            modalName: "课程",
            columns: [
                {
                    checkbox: true
                },
                {
                    field: 'courseId',
                    title: '课程Id',
                    width: '80px'
                },
                {
                    field: 'courseName',
                    title: '课程名称'
                },
                {
                    field: 'categoryName',
                    title: '专业',
                    width: '120px'
                },
                {
                    field: 'price',
                    align: 'center',
                    title: '价格',
                    width: '80px',
                    formatter: function (value, row, index) {
                        return value / 100
                    }
                },
                {
                    field: 'lessonNum',
                    align: 'center',
                    title: '课时',
                    width: '80px'
                }]
        };
        $.table.init(options);
    });

    function courseChoice() {
        table.set();
        var rowss = $('#bootstrap-table').bootstrapTable('getSelections');//行的数据
        if (rowss.length === 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        var couArr = [];
        for (var i = 0; i < rowss.length; i++) {
            var id = rowss[i].courseId;
            couArr.push(id);
        }
        window.parent.addCou(couArr);
        window.parent.layer.closeAll();
    }

    function closeIndesx() {
        window.parent.layer.closeAll();
    }
</script>
</body>
</html>